﻿





CREATE PROCEDURE [dbo].[proc_Employee_Wage_GetItem]
	(
		@Id int
	)
AS
	Select 
	(isnull((select Wage from Grade where id=E.GradeId),0)) as BasicWage
	,(isnull((select p.PostWage from Post p where p.id=E.PostId),0)) as PostWage
	,(datediff(mm,ISNULL(e.RuzhiDate,GetDate()),GetDate())/12*100) as WorkWage
	--,(datediff(dd,ISNULL(e.ZzDate,GetDate()),GetDate())/365*100) as WorkWage
	,(isnull((select JxWage from Post where id=E.PostId),0)) as JxWage
	,(isnull((select ManQin from Post where id=E.PostId),0)) as ManQin
	,(isnull((SELECT top(1) isnull(QtAllowance,0) FROM Employee_Wage w where w.UserName=E.UserName  order by w.CreateDate desc),0)) as QtAllowance
	,IsNull((Select Sum(FA.Amount) From Employee_FixedAllowance FA Where FA.UserName = E.UserName ),0) as FAllowance
	,ISNULL((Select Sum(EA.Amount) From Employee_Allowance EA Where PostId=e.PostId and EA.Pid=E.Pid and EA.Cid=E.Cid),0) as Allowance
	From Employee E
	Where E.Id=@Id
	RETURN





